﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Server.WarehouseManage.OutWarehouseServer;
using SmartWMS.Server.WarehouseManage.OutWarehouseServer.Dto;

namespace SmartWMS.API.Controllers.WarehouseManage
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "Warehouse")]
    public class OutWarehousesController : ControllerBase
    {
        private readonly IOutWarehouseServers outWarehouseServers;

        public OutWarehousesController(IOutWarehouseServers outWarehouseServers)
        {
            this.outWarehouseServers = outWarehouseServers;
        }

        /// <summary>
        /// 出库管理列表
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<List<OutWarehouseDtoPuls>>> GetOutWarehouseDtoPes(OutWarehouseDtoPage dto) {
            try
            {
                var list =await outWarehouseServers.GetOutWarehouseDtoPes(dto);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<OutWarehouseDtoPes>> GetViewOutWarehouse(OutWarehouseDtoPes dto) { 
        var list= await outWarehouseServers.GetViewOutWarehouse(dto);
            return list;
        }
        /// <summary>
        /// 审核出库状态
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateStateOutWare(OutWarehouseDtoPes dto) { 
        var result= await outWarehouseServers.UpdateStateOutWare(dto);
            return result;
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> DelOutWare(OutWarehouseDtoPes dto) {
            var result = await outWarehouseServers.DelOutWare(dto);
            return result;
        }

        /// <summary>
        /// 批量删除数据（）
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> DeleteOutWare(List<OutWarehouseDtoPes> dto) {
            var result = await outWarehouseServers.DeleteOutWare(dto);
            return result;
        }
        /// <summary>
        /// 添加出库出库明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> AddOutWare(OutWarehouseDtoPes dto) { 
         var list= await outWarehouseServers.AddOutWare(dto);
            return list;
        }
        /// <summary>
        /// 联想查询
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<List<SalesDtoPas>>> Getassociation(OutWarehouseDtoPage dto) { 
        var list= await outWarehouseServers.Getassociation(dto);
            return list;
        }
        /// <summary>
        /// 反填数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public OutWarehouseDtoPes ReckOutWare(OutWarehouseDtoPage dto) { 
            var list = outWarehouseServers.ReckOutWare(dto);
            return list;
        }
        /// <summary>
        /// 批量修改数据
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateOutWare(OutWarehouseDtoPes dto) { 
            var list = await outWarehouseServers.UpdateOutWare(dto);
            return list;
        }

    }
}
